package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ADictArea;
import com.ruoyi.system.service.IADictAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 字典房屋面积Controller
 *
 * @author gf
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/system/aDictArea")
public class ADictAreaController extends BaseController {
    @Autowired
    private IADictAreaService aDictAreaService;

    /**
     * 查询字典房屋面积列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ADictArea aDictArea) {
        startPage();
        List<ADictArea> list = aDictAreaService.selectADictAreaList(aDictArea);
        return getDataTable(list);
    }

    /**
     * 导出字典房屋面积列表
     */
    @Log(title = "字典房屋面积", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ADictArea aDictArea) {
        List<ADictArea> list = aDictAreaService.selectADictAreaList(aDictArea);
        ExcelUtil<ADictArea> util = new ExcelUtil<>(ADictArea.class);
        util.exportExcel(response, list, "字典房屋面积数据");
    }

    /**
     * 获取字典房屋面积详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(aDictAreaService.selectADictAreaById(id));
    }

    /**
     * 新增字典房屋面积
     */
    @Log(title = "字典房屋面积", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ADictArea aDictArea) {
        return toAjax(aDictAreaService.insertADictArea(aDictArea));
    }

    /**
     * 修改字典房屋面积
     */
    @Log(title = "字典房屋面积", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ADictArea aDictArea) {
        return toAjax(aDictAreaService.updateADictArea(aDictArea));
    }

    /**
     * 删除字典房屋面积
     */
    @Log(title = "字典房屋面积", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(aDictAreaService.deleteADictAreaByIds(ids));
    }

    /**
     * 逻辑删除字典房屋面积
     */
    @Log(title = "字典房屋面积", businessType = BusinessType.DELETE)
    @DeleteMapping("/logicDel/{ids}")
    public AjaxResult logicDel(@PathVariable Long[] ids) {
        return toAjax(aDictAreaService.deleteADictAreaByIds(ids));
    }

    @GetMapping("/allList")
    public AjaxResult allList() {
        return success(aDictAreaService.selectADictAreaAllList());
    }
}
